DayOfWeek

DayOfWeek and WeekDay are equivalent functions. However, WeekDay is preferred in Basic syntax and DayOfWeek is preferred in Crystal syntax.

Overloads
Arguments

date is a Date value or dateTime value.

Returns

Whole Number

Action

DayOfWeek determines the day of the week the given date falls on, and converts the day of the week to a Number (1 to 7). Optionally a numeric value for the first day of the week can be specified. If the first day of the week is not specified, Sunday is assumed.

Typical uses

Use this function any time you need to use the day of the week as a Number.

Examples

The following examples are applicable to Crystal syntax:

DayOfWeek(Date(1990,10,1))

Returns 2 where October 1, 1990 is a Monday.

If DayOfWeek({orders.ORDER DATE}) = 3 Then

    "Sam"

Else

    "Bill"

In determining whether Sam or Bill was on duty on September 8, 1990.

If DayOfWeek({orders.ORDER DATE}) = 7 Then

    "Saturday"

Else

    ""


DayOfWeek(#Sept. 24, 1999#, crMonday)

Returns 5 where Sept. 24, 1999, is a Friday, and Monday is specified to be the first day of the week.

Comments

If you want to get the day of the week spelled out, in Crystal syntax, use this formula:

["Sun", "Mon", "Tues",...] [DayOfWeek(Date)]

Sets up an array (["Sun",...]) and uses the number of the day of the week (Sun = 1, Sat = 7) to select the desired date name from the array.

Related topics

Formula 10



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com